/**
 * 店铺相关API
 */

import {http, Method} from '@/utils/request.js';


import api from "@/config/api.js";

/**
 * 获取店铺列表
 * @param params
 */
export function getStoreList(params) {
  return http.request({
    url: api.store+'/store/store',
    method: Method.GET,
    params,
  });
}

/**
 * 获取店铺基本信息
 * @param storeId
 */
 export function getStoreBaseInfo(storeId) {
  return http.request({
    url: api.store+`/store/store/get/detail/${storeId}`,
    method: Method.GET,
    loading: false,
  });
}

/**
 * 获取店铺信息
 * @param storeId
 * @returns {*}
 */
export function getStoreInfo(storeId) {
    return http.request({
        url: api.store+`/store/store/get/${storeId}`,
        method: Method.GET,
        loading: false,
    });
}



/**
 * 获取店铺分类
 * @param id
 */
 export function getStoreCategory(id) {
  return http.request({
    url: api.store+`/store/store/label/get/${id}`,
    method: Method.GET,
  });
}
///get/getStoreByMember
export function getStoreByMember(id) {
  return http.request({
    url: api.store+`/store/store/get/getStoreByMember/${id}`,
    method: Method.GET
  });
}

/**
 * 营业执照
 * @param id
 */
 export function getLicencePhoto(id) {
  return http.request({
    url: api.store+`/store/store/get/licencePhoto/${id}`,
    method: Method.GET,
  });
}


/**
 * 获取自提点信息
 * @param id
 */
 export function getStoreAddress(storeId,params) {
  return http.request({
    url: api.store+`/store/address/page/${storeId}`,
    method: Method.GET,
    params
  });
}

//添加优惠劵savePlatformCoupon
export function savePlatformCoupon(params) {
  return http.request({
    url:api.store+ `/store/promotion/coupon`,
    method: Method.POST,
    data:params
  });
}


//updateStoreCoupon
export function updateStoreCoupon(params) {
    return http.request({
        url:api.store+ `/store/promotion/coupon`,
        method: Method.PUT,
        data:params
    });
}
/**
 * 获取优惠券详情
 * @param params
 * @returns {*}
 */
export function selectStoreCouponByCouponId(couponId) {
    return http.request({
        url: api.store+"/store/promotion/coupon/" + couponId,
        method: Method.GET
    })
}

/**
 * selectStoreCouponList
 * 获取优惠劵列表
 */
export function selectStoreCouponList(params) {
    return http.request({
        url: api.store+"/store/promotion/coupon",
        method: Method.GET,
        params
    })
}

/**
 * 分页获取店员列表  getClerkList
 */
export function getClerkList(params) {
    return http.request({
        url: api.store+"/store/store/getClerkList",
        method: Method.GET,
        params
    })
}


/**
 * 获取经纪人列表getClerkListAll
 */
export function getClerkListAll(params) {
    return http.request({
        url: api.store+"/store/store/getClerkListAll",
        method: Method.GET,
        params
    })
}

/**
 * addClerk
 */
export function addClerk(params) {
    return http.request({
        url: api.store+"/store/clerk",
        method: Method.POST,
        data:params
    })
}

/**
 * 修改店员信息
 */
export function updateClerk(params) {
    return http.request({
        url: api.store+"/store/clerk",
        method: Method.PUT,
        data:params
    })
}

/**
 * 获取店员详细
 */
export function getClerkDetail(clerkId) {
    return http.request({
        url: api.store+"/store/clerk/" + clerkId,
        method: Method.GET
    })
}

/**
 * 通过用户Id  获取店员
 */
export function getClerkByUserId(userId) {
    return http.request({
        url: api.store+"/store/clerk/getByUserId/" + userId,
        method: Method.GET
    })
}


/**
 * 删除店员 -deleteClerk
 */
export function deleteClerk(clerkId) {
    return http.request({
        url: api.store+"/store/clerk/delByIds/" + clerkId,
        method: Method.DELETE
    })
}


/**
 * 审核店铺
 * @PutMapping(value = "/audit/{id}/{passed}")
 */
export function auditStore(storeId,passed) {
    return http.request({
        url: api.store+"/manager/store/store/audit/"+storeId+"/"+passed,
        method: Method.PUT
    })
}

/**
 * 关闭店铺 @PutMapping(value = "/disable/{id}")
 */
export function disableStore(storeId) {
    return http.request({
        url: api.store+"/manager/store/store/disable/"+storeId,
        method: Method.PUT
    })
}

/**
 * 开启店铺 @PutMapping(value = "/enable/{id}")
 */
export function enableStore(storeId) {
    return http.request({
        url: api.store+"/manager/store/store/enable/"+storeId,
        method: Method.PUT
    })
}

/**
 * 拒绝店铺申请
 * PutMapping(value = "/refused/{id}/{content}")
 */
export function refusedStore(storeId,content) {
    return http.request({
        url: api.store+"/manager/store/store/refused/"+storeId+"/"+content,
        method: Method.PUT
    })
}

/**
 * 获取店铺列表
 * @param params
 */
export function getStoreListAll() {
    return http.request({
        url: api.store+'/manager/store/store/all2',
        method: Method.GET
    });
}

/**
 * 根据会员id查询店铺信息
 *  @GetMapping("/{memberId}/member")
 */
export function getMemberInfo(memberId) {
    return http.request({
        url:  api.store+`/manager/store/store/${memberId}/member`,
        method: Method.GET,
        needToken: true,
    });
}

/**
 *
 */
export function getStaUserCount() {
    return http.request({
        url: api.store+"/store/store/getStaUserCount",
        method: Method.GET
    })
}